/*
 * @Author: zhang_gen_yuan
 * @Date: 2021-08-15 10:49:21
 * @LastEditTime: 2021-08-16 11:07:58
 * @Descripttion: 
 */

import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router';

import asyncRoutes from './layoutRutes'
import constantRoutes from './constantRoutes'

const createRouters = createRouter({
  history: createWebHistory(),
  routes: constantRoutes.concat(asyncRoutes),
  scrollBehavior: (to, from) => ({ left: 0, top: 0 }),
})

const router = createRouters;

export function resetRouter() {
  const WHITE_NAME_LIST = [
    'Login',
  ]
  router.getRoutes().forEach((route) => {
    const { name } = route;
    if (name && !WHITE_NAME_LIST.includes(name)) {
      router.hasRoute(name) && router.removeRoute(name);
    }
  });
}

export default router